package com.llu.jackson.poc.CVE_2020_25649;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ext.DOMDeserializer;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import org.w3c.dom.Document;

import java.io.IOException;

public class MainTest {

    public static void main(String[] args) throws IOException {

        // 创建 XmlMapper 实例
        ObjectMapper mapper = new XmlMapper();
        // 注册 DOMDeserializer
//        SimpleModule module = new SimpleModule();
//        module.addDeserializer(Document.class, new DOMDeserializer.DocumentDeserializer());
//        mapper.registerModule(module);

        // 示例 XML 文本
        String json = "<root><userName>admin</userName></root>";


        // 反序列化 XML 文本到 Document 对象
        Person person = mapper.readValue(json, Person.class);

        // 处理 Document 对象
        System.out.println(person.getUserName()); // 输出 "root"

    }
}
